<?php $this->load->view('partial/head'); ?>

<script>
$(function(){
	$('.dataTables').dataTable();
});
</script>

<h1>List Kuisioner</h1>

<a href="<?=base_url()."index.php/cs/add_kuisioner/"?>" style="margin-bottom: 20px; display: block">Tambah Kuisioner</a>

<?php if($pesan != NULL){
	echo "<div class='form-info ".($pesan['success'] ? 'success' : 'fail')."'>".$pesan['pesan']."</div>";
} ?>

<table class="dataTables" cellspacing="0" width="100%">
	<thead>
		<tr>
			<th width="5%">No.</th>
			<th>Pertanyaan</th>
			<th>Pilihan Jawaban</th>
			<th>Status</th>
			<th></th>
		</tr>
	</thead>
	<tbody>
		<?php $no= 1; foreach($kuisioner as $kuisioner){ ?>
			<tr>
				<td><?=$no?></td>
				<td><?=$kuisioner['pertanyaan']?></td>
				<td><?php foreach($kuisioner['pilihan'] as $pilihan){ ?>
						- <?=$pilihan['isi']?> <br/>
					<?php } ?>
				</td>
				<td>
					<?php if($kuisioner['status'] == STATUS_KUISIONER_DRAFT){ ?>
						<a title="Ubah status menjadi Publish" href="<?=base_url()."index.php/cs/edit_status/".$kuisioner['id_kuisioner'].'/'.STATUS_KUISIONER_PUBLISH?>">
							<font color="red">Draft</font>
						</a>
					<?php }else{ ?>
						<a title="Ubah status menjadi Draft" href="<?=base_url()."index.php/cs/edit_status/".$kuisioner['id_kuisioner'].'/'.STATUS_KUISIONER_DRAFT?>">
							<font color="blue">Publish</font>
						</a>
					<?php } ?>
				</td>
				<td>
					<a href="<?=base_url()."index.php/cs/edit_kuisioner/".$kuisioner['id_kuisioner']?>">Edit</a> | 
					<a href="<?=base_url()."index.php/cs/delete_kuisioner/".$kuisioner['id_kuisioner']?>">Hapus</a>
				</td>
			</tr>
		<?php $no++; } ?>
	</tbody>
</table>